package com.yixia.web.controller.monitor;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yixia.common.annotation.Log;
import com.yixia.common.core.controller.BaseController;
import com.yixia.common.core.domain.AjaxResult;
import com.yixia.common.enums.BusinessType;
import com.yixia.common.utils.page.PageBean;
import com.yixia.common.utils.page.PageUtils;
import com.yixia.common.utils.page.TableDataInfo;
import com.yixia.common.utils.poi.ExcelUtil;
import com.yixia.framework.web.service.SysPasswordService;
import com.yixia.system.domain.system.SysOperLog;
import com.yixia.system.service.system.SysOperLogService;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 操作日志记录
 * @author: 依梦
 * @Date 2023/8/25
 */

@ApiOperation("操作日志")
@RestController
@RequestMapping("/monitor/operlog")
public class SysOperlogController extends BaseController {

    @Autowired
    private SysOperLogService operLogService;



    /**
     * 分页查询
     */
    @ApiOperation("分页查询")
    @PreAuthorize("@yixia.hasPermi('monitor:operlog:list')")
    @GetMapping("/list")
    public TableDataInfo list(SysOperLog operLog)
    {
        startPageByHelper();
        List<SysOperLog> list = operLogService.selectOperLogList(operLog);
        return getDataTable(list);
    }

    @ApiOperation("日志导出")
    @Log(title = "操作日志", businessType = BusinessType.EXPORT)
    @PreAuthorize("@yixia.hasPermi('monitor:operlog:export')")
    @PostMapping("/export")
    public void export(HttpServletResponse response, SysOperLog operLog)
    {
        List<SysOperLog> list = operLogService.selectOperLogListPage(new PageBean(), operLog).getRecords();
        ExcelUtil<SysOperLog> util = new ExcelUtil<SysOperLog>(SysOperLog.class);
        util.exportExcel(response, list, "操作日志");
    }




}
